package com.aistar.util;

import java.io.Serializable;

public class ServerResponse implements Serializable {
    private Integer status;
    private Object data;
    private static final long serialVersionUID = 1L;

    //    ===========================================constructor=====================================================
    private ServerResponse(Integer status, Object data) {
        this.status = status;
        this.data = data;
    }

    //    =========================================== get & set =====================================================
    public Integer getStatus() {
        return status;
    }

    public Object getData() {
        return data;
    }

    //    ===========================================新增=====================================================
    public static ServerResponse addSuccess() {
        return addSuccess(MessageUtil.ADD_SUCCESS);
    }

    public static ServerResponse addFailed() {
        return addFailed(MessageUtil.ADD_FAIL);
    }

    public static ServerResponse addSuccess(Object data) {
        return new ServerResponse(MessageUtil.STATUS_SUCCESS, data);
    }

    public static ServerResponse addFailed(Object data) {
        return new ServerResponse(MessageUtil.STATUS_FAIL, data);
    }

    //    ===========================================删除=====================================================
    public static ServerResponse deleteSuccess() {
        return deleteSuccess(MessageUtil.DELETE_SUCCESS);
    }

    public static ServerResponse deleteFailed() {
        return deleteFailed(MessageUtil.DELETE_FAIL);
    }

    public static ServerResponse deleteSuccess(Object data) {
        return new ServerResponse(MessageUtil.STATUS_SUCCESS, data);
    }

    public static ServerResponse deleteFailed(Object data) {
        return new ServerResponse(MessageUtil.STATUS_FAIL, data);
    }

    //    ===========================================修改=====================================================
    public static ServerResponse modifySuccess() {
        return modifySuccess(MessageUtil.MODIFY_SUCCESS);
    }

    public static ServerResponse modifyFailed() {
        return modifyFailed(MessageUtil.MODIFY_FAIL);
    }

    public static ServerResponse modifySuccess(Object data) {
        return new ServerResponse(MessageUtil.STATUS_SUCCESS, data);
    }

    public static ServerResponse modifyFailed(Object data) {
        return new ServerResponse(MessageUtil.STATUS_FAIL, data);
    }

    //    ===========================================查找=====================================================
    public static ServerResponse getSuccess() {
        return getSuccess(MessageUtil.GET_SUCCESS);
    }

    public static ServerResponse getFailed() {
        return getFailed(MessageUtil.GET_FAIL);
    }

    public static ServerResponse getSuccess(Object data) {
        return new ServerResponse(MessageUtil.STATUS_SUCCESS, data);
    }

    public static ServerResponse getFailed(Object data) {
        return new ServerResponse(MessageUtil.STATUS_FAIL, data);
    }
}
